import { AppType, PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

const main = async () => {
    try {
        console.log('Seeding database')

        await prisma.app.deleteMany({})
        await prisma.appGroup.deleteMany({})
        await prisma.chatSession.deleteMany({})
        await prisma.chatMessage.deleteMany({})

        // 通用助手
        const appGroup = await prisma.appGroup.create({
            data: {
                name: 'Default',
                description: 'Commonly used tool sets.',
            }
        })

        await prisma.app.createMany({
            data: [
                {
                    appGroupId: appGroup.id,
                    name: 'Workflow Planning Assistant',
                    type: AppType.ChatBot,
                    description: 'An assistant that helps you plan and select the right node for a workflow (V0.6.0).'
                },
                {
                    appGroupId: appGroup.id,
                    name: 'Question Classifier + Knowledge + Chatbot',
                    type: AppType.ChatBot,
                    description: 'Basic Workflow Template, a chatbot capable of identifying intents alongside with a knowledge base.'
                },
                {
                    appGroupId: appGroup.id,
                    name: 'Knowledge Retreival + Chatbot',
                    type: AppType.ChatBot,
                    description: 'Basic Workflow Template, A chatbot with a knowledge base.'
                },
                {
                    appGroupId: appGroup.id,
                    name: 'Three-Step Translation Workflow',
                    type: AppType.Workflow,
                    description: 'Workflow for enhancing translation accuracy by identifying technical terms, literal translations, pointing out issues with literal translations, and a second translation based on feedback'
                },
                {
                    appGroupId: appGroup.id,
                    name: 'Text Summarization Workflow',
                    type: AppType.Workflow,
                    description: `Based on users' choice, retrieve external knowledge to more accurately summarize articles.`
                },
                {
                    appGroupId: appGroup.id,
                    name: 'SVG Logo Design',
                    type: AppType.Agent,
                    description: `Hello, I am your creative partner in bringing ideas to vivid life! I can assist you in creating stunning designs by leveraging abilities of DALL.E 3.`
                },
                {
                    appGroupId: appGroup.id,
                    name: 'YouTube Channel Data Analysis',
                    type: AppType.Agent,
                    description: `I am a YouTube Channel Data Analysis Copilot, I am here to provide expert data analysis tailored to your needs.`
                },
                {
                    appGroupId: appGroup.id,
                    name: 'Travel Consulatant',
                    type: AppType.Agent,
                    description: `Welcome to your personalized travel service with Consultant! 🌍✈️ Ready to embark on a journey filled with adventure and relaxation? Let's dive into creating your unforgettable travel experience.`
                }
            ],
            skipDuplicates: true
        })

        // 教学助手
        const appGroupT = await prisma.appGroup.create({
            data: {
                name: 'Teaching Assistant',
                description: 'A tool sets for teaching and learning.',
            }
        })

        await prisma.app.createMany({
            data: [
                {
                    appGroupId: appGroupT.id,
                    name: '典型工作岗位分析',
                    type: AppType.Agent,
                    description: '为您解析专业对应的岗位，并详述每个岗位的工作项目与任务。',
                    systemMessage: `
你是一名专业的岗位分析师，请结合行业情况，生成若干个 工作岗位分析 报告
# 输入信息:
    - 岗位名称: {{post}}
    - 其他要求: {{requirement}}
    - 字数要求: {{word_count}}
# 输出数据进行JSON格式化，具体包括 具体岗位名称、责任、技能要求、工作要求
`
                },
                {
                    appGroupId: appGroupT.id,
                    name: '课程体系构建',
                    type: AppType.Agent,
                    description: '创建、管理课程内容、设计学习路径的工具。',
                    systemMessage: `
你是一名专业的教学专家，非常擅长课程体系建设，根据以下要求进行生成一套完整的课程体系
# 输入信息:
    - 专业名称: {{major}}
    - 其他要求: {{requirement}}
    - 字数要求: {{word_count}}
# 输出数据进行JSON格式化，具体包括 所有课程的的名称及该课程所要具备的能力
`
                },
                {
                    appGroupId: appGroupT.id,
                    name: '人才培养课程体系与培养目标对比分析',
                    type: AppType.Agent,
                    description: '人才培养课程体系与培养目标对比分析。',
                    systemMessage: `
你是一名专业的教学专家，非常擅长课程体系建设及分析，根据以下要求进行人才培养课程体系与培养目标对比分析，并生成报告
# 输入信息
    - 专业名称: {{major}}
    - 培养目标: {{goal}}
    - 人培课程列表: {{course_list}}
# 输出数据进行JSON格式化, 具体包括 专业名称, 培养目标, 课程列表, 对比分析 和 结论

# 注意事项
    - 专业名称, 培养目标, 课程列表 按输入信息原样输出，如果不明确则不输出
    - 先展开分析培养目标，然后结合提供的课程体系进行讨论，最后再提供专业的结论报告
    - 如果 培养目标 或 课程列表 不明确，则提供对应的建设性意见
`
                },
                { appGroupId: appGroupT.id, type: AppType.Agent, name: '教案助手', description: '您的智能教学规划助手，为您定制具体、实用的教案，满足不同的教学需求。' },
                { appGroupId: appGroupT.id, type: AppType.Agent, name: '备课内容生成', description: '帮助老师生成备课内容。' },
                { appGroupId: appGroupT.id, type: AppType.Agent, name: '教学计划生成', description: '自动生成教学计划。' },
                { appGroupId: appGroupT.id, type: AppType.Agent, name: '教学大纲生成', description: '根据需求和目标，自动生成详细的教学大纲和教学计划。' },
                { appGroupId: appGroupT.id, type: AppType.Agent, name: '教案设计', description: '辅助教师设计教学计划和教学资源，提升教学效果。' }
            ]
        })

        console.log('Seeding finished')
    } catch (error) {
        console.error(error)
        throw new Error("Failed to seed the database")
    }
}

main()
    .then(async () => {
        await prisma.$disconnect()
    })
    .catch(async (e) => {
        console.error(e)
        await prisma.$disconnect()
        process.exit(-1)
    })